<template>
  <div id="app" v-if="isRouterAlive">
    <DeafaultHead> </DeafaultHead>
    <router-view />
  </div>
</template>

<script>
export default {
  name: "App",
  provide() {
    return {
      reload: this.reload,
    };
  },
  data() { 
    return {
      isRouterAlive: true, //控制视图是否显示的变量
    };
  },
  created() {
    sessionStorage.setItem(
      "declare",
      JSON.stringify(this.$store.state.declare)
    );
    let userInfo = sessionStorage.getItem("userInfo");
    userInfo && this.$store.commit("SET_USER_INFO", JSON.parse(userInfo));
  },
  methods: {
    reload() {
      this.isRouterAlive = false; //先关闭，
      this.$nextTick(function () {
        this.isRouterAlive = true; //再打开
      });
    },
  },
};
</script>
<style>
#app {
  /* display: flex;
  flex-direction: column;
  justify-content: center;
  align-content: center; */
  width: 100%;
  height: calc(100% - 153px);
}
</style>
